﻿#include "CommonResp.h"

CommonResp::CommonResp() : BaseMsg(MSG_TYPE_COMMON_RESP)
{

}

CommonResp::CommonResp(int code, SString result) : BaseMsg(MSG_TYPE_COMMON_RESP)
{
    this->code = code;
    this->result = result;
}

CommonResp::~CommonResp()
{

}

int CommonResp::decodeParametersFromTlv(TLV *tlv)
{
    if (tlv->tag == CommonRespTag_handleResult)
    {
        this->code = tlv->getIntValue();
    }
    else if (tlv->tag == CommonRespTag_resultIllustration)
    {
        this->result = tlv->buffer;
    }
    return f_success;
}

int CommonResp::encodeParametersIntoTlvs(list<TLV *> &tlvs)
{
    tlvs.push_back(createTlvByIntValue(CommonRespTag_handleResult, code));
    tlvs.push_back(createTlvByStringValue(CommonRespTag_resultIllustration, result));
    return f_success;
}

